var BSTMG = BSTMG || {};
BSTMG.userCompListManager = {
	init: function(){
		var that = this;
		//分页功能
		that.selectUserCompList();
	},
	selectUserCompList: function(){
		var userId = $('#userId').val();
		BSTMG.common.hjhPages("/sysAdmin/userAdmin/userCompList",{userId:userId},function(data){
			var userList = data.userList;
			var $tbody = $("#userCompList tbody");
			var $tr = '';
			if(userList.length > 0) {
				for(var i=0;i<userList.length;i++){
					var userInfo = userList[i];
					var loginNum = setLoginNum(userInfo);
					var accountMoney = setAccountMoney(userInfo);
					$tr += '<tr class="odd">';
					$tr += '<td>'+(i+1)+'</td>';
					$tr += '<td>'+BSTMG.tools.checkNull(loginNum)+'</td>';
					$tr += '<td>'+BSTMG.tools.checkNull(toDate(userInfo.addTime,"yyyy-MM-dd hh:mm:ss"))+'</td>';
					$tr += '<td>'+BSTMG.tools.checkNull(userInfo.contactName)+'</td>';
					$tr += '<td>'+parseFloat(accountMoney).toFixed(2)+'</td>';
					$tr += '<td>'+BSTMG.tools.checkNull(userInfo.belongCompanyName)+'</td>';
					$tr += '<td><a class="btn btn-primary" href="/sysAdmin/userAdmin/userDetail/'+userInfo.userId+'">查看详情</a>';
					$tr += '</td></tr>';
				}
				$tbody.html($tr);
			}else {
				var $tr = '<tr class="odd"><td colspan="7">暂无数据！</td></tr>';
				$tbody.html($tr);
			}
		});
	}
}

$(function(){
	BSTMG.userCompListManager.init();
});

//设置登陆账号
function setLoginNum(userInfo){
	if(userInfo.userEmail != "" && userInfo.userEmail != null){
		return userInfo.userEmail;
	}else if(userInfo.userTel != "" && userInfo.userTel != null){
		return userInfo.userTel;
	}else{
		return "";
	}
}
//设置账户余额
function setAccountMoney(userInfo){
	if(userInfo.accountMoney != null ){
		return userInfo.accountMoney;
	}else{
		return 0.00;
	}
}

